﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Data;
using Data.Entity;
namespace ConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            DataContext.CreateDataBase();
            Category category1 = new Category();
            category1.Parent = null;
            category1.Name = "cat1";
            category1.Parent = new Category() { Name = "Parent1" };

            Model model = DataContext.FactoryDataContext();
            model.Categories.AddObject(category1);
            model.SaveChanges();

            foreach (var category in model.Categories)
            {
                Console.WriteLine("Category Name:" + category.Name + "\n");
                if (category.Parent != null)
                    Console.WriteLine("Parent Name:" + category.Parent.Name + "\n");
                else
                    Console.WriteLine("Parent Name: --");

                Console.WriteLine("\n\n");


            }

            Console.ReadKey();
        }


    }
}
